﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Payroll.Biz.Legacy.Utils
{
    public static class DateUtils
    {
        public static bool IsInPayPeriod(DateTime date, DateTime startDate, DateTime endDate)
        {
            return (date >= startDate) && (date <= endDate);
        }

        public static bool IsLastDayOfMonth(DateTime date)
        {
            int m1 = date.Month;
            int m2 = date.AddDays(1).Month;
            return m1 != m2;
        }

        public static int NumberOfFridaysInDayPeriod(DateTime payPeriodStart, DateTime payPeriodEnd)
        {
            int fridays = 0;
            for (DateTime day = payPeriodStart; day <= payPeriodEnd; day = day.AddDays(1))
            {
                if (day.DayOfWeek == DayOfWeek.Friday)
                {
                    fridays++;
                }
            }
            return fridays;
        }
    }
}
